package com.smart.wap.app;

import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.manager.pop.entities.models.PopBasicDiamond;
import com.smart.manager.pop.entities.models.PopBasicDiamondLogs;
import com.smart.utils.MemberAcl;
import com.smart.wap.service.DiamondService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author Administrator
 */

@Api(tags = "移动端-兑换接口")
@RestController
@RequestMapping(SmartConstant.WAP_API_PREFIX + "app/diamond")
@RequiredArgsConstructor
public class DiamondController {

    private final DiamondService diamondService;

    @ApiOperation(value = "获取所有礼包")
    @GetMapping(value = "getDiamondList")
//    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<List<PopBasicDiamond>> getDiamondList() {
        List<PopBasicDiamond> diamondList = diamondService.getDiamondList();
        return AjaxResult.data(diamondList);
    }

    @ApiOperation(value = "兑换指定礼包")
    @GetMapping(value = "addDiamond/{code}")
//    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<String> addDiamond(@PathVariable String code) {
       diamondService.addDiamond(code);
        return AjaxResult.success();
    }

    @ApiOperation(value = "我的兑换记录")
    @GetMapping(value = "getDiamondLogList")
//    @SaCheckLogin(type = MemberStp.TYPE)
    public AjaxResult<List<PopBasicDiamondLogs>> getDiamondLogList( ) {
        List<PopBasicDiamondLogs> diamondLogList = diamondService.getDiamondLogList(MemberAcl.getLoginId());
        return AjaxResult.data(diamondLogList);
    }


}
